﻿using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Miao.UI;
using Miao;
using TMPro;
using DG.Tweening;
using UnityEngine.UI;
using UnityEngine.EventSystems;

[SourcesPath("Assets/Plugins/Miao/UIPrefab/SoundSetting.prefab")]
public class SoundSettingPanel : UIPanel
{
    public AudioClip soundChangeClip;
    public Slider musicSlider;
    public Slider soundSlider;
    private void Start()
    {
        musicSlider.value = SoundManager.MusicVolume;
        soundSlider.value = SoundManager.SoundVolume;
        musicSlider.onValueChanged.AddListener(MusicChange);
        soundSlider.onValueChanged.AddListener(SoundChange);
    }

    private void MusicChange(float value)
    {
        SoundManager.MusicVolume = value;
    }

    private void SoundChange(float value)
    {
        SoundManager.SoundVolume = value;

        if(!SoundManager.soundPlay.isPlaying)
        {
            SoundManager.soundPlay.clip = soundChangeClip;
            SoundManager.soundPlay.volume = value;
            SoundManager.soundPlay.Play();
        }
    }

}
